package com.pyk.service.impl;


import com.pyk.entity.Question;
import com.pyk.mapper.QuestionMapper;
import com.pyk.service.QuestionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.List;

@Slf4j
@Service
public class QuestionServiceImpl implements QuestionService {

    @Autowired
    private QuestionMapper questionMapper;

    public void add(Question question)
    {
        questionMapper.insert(question);
    }

    public void updateById(Question question) {
        questionMapper.updateById(question);
    }

    public void deleteById(Long id) {
        questionMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids) {
            questionMapper.deleteById((id.longValue()));
        }
    }

    public Question findById(Long id) {
        return questionMapper.selectById(id);
    }

    /**
     * 查找所有符合条件的题目 如果为空 那么就不为约束
     * @param question
     * @return
     */
    public List<Question> findAll(Question question)
    {
        return questionMapper.selectAll(question);
    }
}
